package com.zijie.shoprbacapi.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.rbac.model.UserGroup;
import com.zijie.rbac.service.UserGroupService;
import com.zijie.shoprbacapi.mapper.UserGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserGroupServiceImpl implements UserGroupService {
    private UserGroupMapper userGroupMapper;

    @Autowired
    public void setUserGroupMapper(UserGroupMapper userGroupMapper) {
        this.userGroupMapper = userGroupMapper;
    }

    @Override
    public Page<UserGroup> findAll(Page<UserGroup> page, UserGroup usb) {
        return userGroupMapper.findAll(page,usb);
    }

    @Override
    public int add(UserGroup userGroup) {
        return userGroupMapper.insert(userGroup);
    }

    @Override
    public int update(UserGroup userGroup) {
        return userGroupMapper.updateById(userGroup);
    }

    @Override
    public int deleteById(Integer id) {
        return userGroupMapper.deleteById( id);
    }

    @Override
    public int deleteByIds(List<Integer> ids) {
        return userGroupMapper.deleteByIds(ids);
    }

    @Override
    public boolean assignAdminToGroup(Long adminId, Long userGroupId) {
        return userGroupMapper.assignAdminToGroup(adminId, userGroupId);
    }

    @Override
    public void assignRole(Long userGroupId, Long roleId) {
        userGroupMapper.assignRole(userGroupId, roleId);
    }
}
